<?php
class Control_Uploadbutton extends QUI_Control_Abstract
{
	function render()
	{
		$data = $this->attrs();
		if(empty($data['class'])) $data['class'] = '';
		$data['class'] .= " dfinput";
		$out = "";
		$host = Helper_Common::getJiqunHost();
		$upurl = url('admin::interface/uploadeditor');
		$out .= <<<EOT
<input type="button" class='jmwup' value="上传文件" id="b{$this->id()}">
<script type="text/javascript">
$('#b{$this->id()}').upload({
	action: '{$upurl}',
	onComplete: function(data) {
		var obj = eval('('+ data +')');
		if(obj.err == '' && obj.msg.url)
		{
			$('#{$this->id()}').val('{$host}'+obj.msg.url.substr(1));
			alert('上传成功');
		}else{
			alert(obj.err);
		}
	}
});
</script>
EOT;
		$out.= Q::control('textbox', $this->id(),$data )->render();
		return $out;
	}
}